<?php
/*
Engineer: Derek Shue
Updated: 12/04/2011
Description: Displays a table of current volunteer requests and courses, allows the ability
to search both lists by date and allows admins to see current course associations.

*/
?>

<div style = "display: inline;">
<?php
$this->form->setAction($this->url());
$courses = new Application_Model_DbTable_Courses();

$volunteerrequests = new Application_Model_DbTable_VolunteerRequests();
$volquery = new Application_Model_VolunteerQuery();
echo $this->form;
?>
</div>

<a href = <?php echo $this->url(array('controller' => 'admin', 'action' => 'addcourseassociation')) ?> > <h3><b> Add Course Association</b></h3> </a>

<div style = "display: inline;">
<?php
//if no associations found 
if($this->associates):?>
<h3>Course Associations found:</h3>
<table>
    <tr>
        <th>Course Name</th>
        <th>Volunteer Request</th>
        <th>Positions Received</th>
		<th>Term</th>
    </tr>
	<tr></tr>
    <?php foreach($this->associates as $associate): ?> 
	
	<?php 
	//
	$coursename = $courses->getCourse("CID = " . $associate['CID']);	
	$requestname = $volunteerrequests->getVolunteerRequest("VRID = " . $associate['RID']);
	$positionsreceived = $associate['NUMPOSITIONS'];
	$term = $associate['TERM'];
	?>
	
		<tr align = "center">
		<td> <a href = <?php echo $this->url(array('controller'=>'common', 'action' => 'viewcoursedetails', 'cid' => $coursename['CID'])) ?>> <?php echo $coursename['DEPARTMENT'] . $coursename['COURSENUMBER']?> </a> </td> 
		<td> <?php echo $volquery->getPartnerNameForVRID($associate['RID'])."-".$requestname['POSITIONTITLE']?> </td> 
		<td> <?php echo $positionsreceived?> </td> 
		<td> <?php echo $term?> </td>
		</tr>

    <?php endforeach ?>
    
</table>
<?php endif; ?>
</div>




<?php 
//if no associations found
if(!$this->associates):?>
	<h3>No course associations found.</h3>
<?php endif; ?>



<?php //if volunteer requests found
if($this->positions):?>
<h3>Volunteer Requests found:</h3>
<table>
    <tr>
        <th>Position</th>
        <th>Term</th>
        <th>Positions Requested</th>
    </tr>
    <tr>
    <?php foreach($this->positions as $pos): ?>
    <tr align = "center">
        <td><a href =
		<?php echo $this->url(array('controller'=>'common','action'=>'viewvrdetails','vrid'=>$pos['VRID'])); ?>
		><?php echo $volquery->getPartnerNameForVRID($pos['VRID'])."-".$pos['POSITIONTITLE'] ?></a></td>
	<td><?php echo $pos['TERM'] ?></td>
        <td><?php echo $pos['NUMBERREQUESTING'] ?></td> 	
    </tr>
    <?php endforeach ?>
    </tr>
</table>
<?php endif; ?>
<?php if(!$this->positions):?>
	<h3>No volunteer requests found.</h3>
<?php endif; ?>


